
package cn.edu.scau.cmi.hombio.service;

import cn.edu.scau.cmi.hombio.domain.Medicine;
import cn.edu.scau.cmi.hombio.domain.MedicineStorage;
import cn.edu.scau.cmi.hombio.domain.MedicineStorageDetail;

import java.util.List;
import java.util.Set;

import org.junit.Test;

import org.junit.runner.RunWith;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.beans.factory.support.DefaultListableBeanFactory;

import org.springframework.context.ApplicationContext;

import org.springframework.mock.web.MockHttpServletRequest;

import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestExecutionListeners;

import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
import org.springframework.test.context.support.DirtiesContextTestExecutionListener;

import org.springframework.test.context.transaction.TransactionalTestExecutionListener;

import org.springframework.transaction.annotation.Transactional;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.RequestScope;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.context.request.SessionScope;

/**
 * Class to run the service as a JUnit test. Each operation in the service is a separate test.
 *
 */

@RunWith(SpringJUnit4ClassRunner.class)
@TestExecutionListeners({
		DependencyInjectionTestExecutionListener.class,
		DirtiesContextTestExecutionListener.class,
		TransactionalTestExecutionListener.class })
@ContextConfiguration(locations = {
		"file:./resources/pigRs-security-context.xml",
		"file:./resources/pigRs-service-context.xml",
		"file:./resources/pigRs-dao-context.xml",
		"file:./resources/pigRs-web-context.xml" })
@Transactional
public class MedicineStorageDetailServiceTest {

	/**
	 * The Spring application context.
	 *
	 */
	@SuppressWarnings("unused")
	private ApplicationContext context;

	/**
	 * The service being tested, injected by Spring.
	 *
	 */
	@Autowired
	protected MedicineStorageDetailService service;

	/**
	 * Instantiates a new MedicineStorageDetailServiceTest.
	 *
	 */
	public MedicineStorageDetailServiceTest() {
		setupRequestContext();
	}

	/**
	 * Operation Unit Test
	 */
	@Test
	public void findMedicineStorageDetailByPrimaryKey() {
		// TODO: JUnit - Populate test inputs for operation: findMedicineStorageDetailByPrimaryKey 
		Integer id = 0;
		MedicineStorageDetail response = null;
		response = service.findMedicineStorageDetailByPrimaryKey(id);
		// TODO: JUnit - Add assertions to test outputs of operation: findMedicineStorageDetailByPrimaryKey
	}

	/**
	 * Operation Unit Test
	* Delete an existing MedicineStorageDetail entity
	* 
	 */
	@Test
	public void deleteMedicineStorageDetail() {
		// TODO: JUnit - Populate test inputs for operation: deleteMedicineStorageDetail 
		MedicineStorageDetail medicinestoragedetail = new cn.edu.scau.cmi.hombio.domain.MedicineStorageDetail();
		service.deleteMedicineStorageDetail(medicinestoragedetail);
	}

	/**
	 * Operation Unit Test
	* Delete an existing MedicineStorage entity
	* 
	 */
	@Test
	public void deleteMedicineStorageDetailMedicineStorage() {
		// TODO: JUnit - Populate test inputs for operation: deleteMedicineStorageDetailMedicineStorage 
		Integer medicinestoragedetail_id = 0;
		Integer related_medicinestorage_id = 0;
		MedicineStorageDetail response = null;
		response = service.deleteMedicineStorageDetailMedicineStorage(medicinestoragedetail_id, related_medicinestorage_id);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteMedicineStorageDetailMedicineStorage
	}

	/**
	 * Operation Unit Test
	* Save an existing Medicine entity
	* 
	 */
	@Test
	public void saveMedicineStorageDetailMedicine() {
		// TODO: JUnit - Populate test inputs for operation: saveMedicineStorageDetailMedicine 
		Integer id_1 = 0;
		Medicine related_medicine = new cn.edu.scau.cmi.hombio.domain.Medicine();
		MedicineStorageDetail response = null;
		response = service.saveMedicineStorageDetailMedicine(id_1, related_medicine);
		// TODO: JUnit - Add assertions to test outputs of operation: saveMedicineStorageDetailMedicine
	}

	/**
	 * Operation Unit Test
	* Save an existing MedicineStorage entity
	* 
	 */
	@Test
	public void saveMedicineStorageDetailMedicineStorage() {
		// TODO: JUnit - Populate test inputs for operation: saveMedicineStorageDetailMedicineStorage 
		Integer id_2 = 0;
		MedicineStorage related_medicinestorage = new cn.edu.scau.cmi.hombio.domain.MedicineStorage();
		MedicineStorageDetail response = null;
		response = service.saveMedicineStorageDetailMedicineStorage(id_2, related_medicinestorage);
		// TODO: JUnit - Add assertions to test outputs of operation: saveMedicineStorageDetailMedicineStorage
	}

	/**
	 * Operation Unit Test
	* Return a count of all MedicineStorageDetail entity
	* 
	 */
	@Test
	public void countMedicineStorageDetails() {
		Integer response = null;
		response = service.countMedicineStorageDetails();
		// TODO: JUnit - Add assertions to test outputs of operation: countMedicineStorageDetails
	}

	/**
	 * Operation Unit Test
	* Return all MedicineStorageDetail entity
	* 
	 */
	@Test
	public void findAllMedicineStorageDetails() {
		// TODO: JUnit - Populate test inputs for operation: findAllMedicineStorageDetails 
		Integer startResult = 0;
		Integer maxRows = 0;
		List<MedicineStorageDetail> response = null;
		response = service.findAllMedicineStorageDetails(startResult, maxRows);
		// TODO: JUnit - Add assertions to test outputs of operation: findAllMedicineStorageDetails
	}

	/**
	 * Operation Unit Test
	* Delete an existing Medicine entity
	* 
	 */
	@Test
	public void deleteMedicineStorageDetailMedicine() {
		// TODO: JUnit - Populate test inputs for operation: deleteMedicineStorageDetailMedicine 
		Integer medicinestoragedetail_id_1 = 0;
		Integer related_medicine_id = 0;
		MedicineStorageDetail response = null;
		response = service.deleteMedicineStorageDetailMedicine(medicinestoragedetail_id_1, related_medicine_id);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteMedicineStorageDetailMedicine
	}

	/**
	 * Operation Unit Test
	* Load an existing MedicineStorageDetail entity
	* 
	 */
	@Test
	public void loadMedicineStorageDetails() {
		Set<MedicineStorageDetail> response = null;
		response = service.loadMedicineStorageDetails();
		// TODO: JUnit - Add assertions to test outputs of operation: loadMedicineStorageDetails
	}

	/**
	 * Operation Unit Test
	* Save an existing MedicineStorageDetail entity
	* 
	 */
	@Test
	public void saveMedicineStorageDetail() {
		// TODO: JUnit - Populate test inputs for operation: saveMedicineStorageDetail 
		MedicineStorageDetail medicinestoragedetail_1 = new cn.edu.scau.cmi.hombio.domain.MedicineStorageDetail();
		service.saveMedicineStorageDetail(medicinestoragedetail_1);
	}

	/**
	 * Autowired to set the Spring application context.
	 *
	 */
	@Autowired
	public void setContext(ApplicationContext context) {
		this.context = context;
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("session", new SessionScope());
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("request", new RequestScope());
	}

	/**
	 * Sets Up the Request context
	 *
	 */
	private void setupRequestContext() {
		MockHttpServletRequest request = new MockHttpServletRequest();
		ServletRequestAttributes attributes = new ServletRequestAttributes(request);
		RequestContextHolder.setRequestAttributes(attributes);
	}
}
